在C#中如何输出"*"组成的如下三角
来源:百度知道 编辑:UC知道 时间:2024/05/27 05:20:20
*
**
***
****
**
***
****
using System;
using System.Collections.Generic;
using System.Text;
namespace 棱形
{
class Program
{
static void Main(string[] args)
{
Console.Write("请输入一个数值:");
int a = Int32.Parse(Console .ReadLine() );
for (int i = 1; i <= a; i++)
{
for (int n = 1; n <= a - i; n++)
{
Console.Write(" ");
}
for (int j = 1; j <= i; j++)
{
Console.Write("* ");
}
Console.WriteLine();
}
for (int i = 1; i <= a; i++)
{
for (int n = 1; n <= i; n++)
{
Console.Write(" ");
}
for (int j = 1; j <= a - i; j++)
{
Console.Write("* ");
}
Console.WriteLine();
}
Console.ReadLine();
}
}
}
自己看看
using System;
using System.Collections.Generic;
using System.Text;